package com.ruoyi.jeeplus.modules.screen.frontdesk.screen_fire_alarm.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.jeeplus.modules.screen.frontdesk.screen_fire_alarm.domain.Frontdesk_fire_alarm;
import com.ruoyi.jeeplus.modules.screen.frontdesk.screen_fire_alarm.mapper.Frontdesk_fire_alarmMapper;
import com.ruoyi.jeeplus.modules.screen.frontdesk.screen_fire_alarm.service.Frontdesk_fire_alarmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 刘奥旸
 * @version 1.0
 */
@RestController
public class Frontdesk_fire_alarmController {
    @Autowired
    Frontdesk_fire_alarmMapper frontdeskFireAlarmMapper;
    @Autowired
    private Frontdesk_fire_alarmService fireAlarmService;


    @GetMapping(value = "/lay/lay1")
    public List<Frontdesk_fire_alarm> a322(){
        List<Frontdesk_fire_alarm> frontdeskFireAlarms = frontdeskFireAlarmMapper.selectAllFireAlarms();

        return frontdeskFireAlarms;
    }
    @GetMapping(value = "/lay/fire_alarm")
    public Map<String, Object> getPagedFireAlarms(
            @RequestParam(defaultValue = "1") int page,
            @RequestParam(defaultValue = "10") int pageSize) {
        List<Frontdesk_fire_alarm> alarms = fireAlarmService.getPagedFireAlarms(page, pageSize);
        int total = frontdeskFireAlarmMapper.countAllFireAlarms();
        Map<String, Object> response = new HashMap<>();
        response.put("data", alarms);
        response.put("total", total);
        response.put("page", page);
        response.put("pageSize", pageSize);

        return response;
    }
    int i = 0;
    @GetMapping(value = "/lay/openwindow")
    public boolean openwindow(){

        if (i == 1){
            return false;
            }else {
            return true;
            }
    }
    @GetMapping(value = "/lay/exer123")
    public String exer(@RequestParam int e){
        i = e;
        String ie = i + "";
     return "ok" + ie;
    }
}
